package com;

import java.sql.*;

public class Text3 {
    public int fun(String name,int id) throws ClassNotFoundException, SQLException {
        Connection conn =null;
        ResultSet rs =null;
        int new1=0;
        PreparedStatement preparedStatement =null;
        try{
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/kgcnews", "root", "123456");
            String sql = "UPDATE new_category SET name=? WHERE id=?";
            preparedStatement=conn.prepareStatement(sql);
            preparedStatement.setString(1,name);
            preparedStatement.setInt(2,id);
            new1 = preparedStatement.executeUpdate();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {


            preparedStatement.close();
            conn.close();
        }
        return 1;
    }
}
